package com.zgjkhis.modules.system.rest;

import com.zgjkhis.domain.PageResult;
import com.zgjkhis.logging.aop.log.Log;
import com.zgjkhis.modules.system.domain.TcmDiseases;
import com.zgjkhis.modules.system.service.TcmDiseasesService;
import com.zgjkhis.modules.system.service.dto.TcmDiseasesQueryCriteria;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @date 2018-11-23
 */
@Api(tags = "诊断管理：诊断管理")
@RestController
@RequestMapping("/tcmdiseases")
public class TcmDiseasesController {

    private static final String ENTITY_NAME = "tcmDiseaseService";
    private final TcmDiseasesService tcmDiseasesService;

    public TcmDiseasesController(TcmDiseasesService tcmDiseasesService) {
        this.tcmDiseasesService = tcmDiseasesService;
    }


    @Log("查询诊断")
    @ApiOperation("查询诊断")
    @GetMapping(value = "/list")
//    @PreAuthorize("@el.check('supplier:list')")
    public ResponseEntity<PageResult<TcmDiseases>> list(TcmDiseasesQueryCriteria criteria, Pageable pageable){
//        QueryWrapper<TcmDiseases> queryWrapper = new QueryWrapper<>();
//        if (!CharUtil.isEmpty(tcmDiseases.getPinyinCode())) {
//            queryWrapper.lambda().or().like(TcmDiseases::getPinyinCode, tcmDiseases.getPinyinCode());
//
//        }
//        if (!CharUtil.isEmpty(tcmDiseases.getDiseasesName())) {
//            queryWrapper.lambda().or().like(TcmDiseases::getDiseasesName, tcmDiseases.getDiseasesName());
//        }
//        if (!CharUtil.isEmpty(tcmDiseases.getDiseasesCode())) {
//            queryWrapper.lambda().or().like(TcmDiseases::getDiseasesCode, tcmDiseases.getDiseasesCode());
//        }
//        if (!CharUtil.isEmpty(tcmDiseases.getRemark())) {
//            queryWrapper.lambda().or().like(TcmDiseases::getRemark, tcmDiseases.getRemark());
//        }
//        if (!CharUtil.isEmpty(tcmDiseases.getIsUsed())) {
//            queryWrapper.lambda().eq(TcmDiseases::getIsUsed, tcmDiseases.getIsUsed());
//        }
//        queryWrapper.lambda().orderByDesc(TcmDiseases::getIsUsed);
//        queryWrapper.lambda().orderByAsc(TcmDiseases::getSort);
//        if (!CharUtil.isEmpty(tcmDiseases.getPinyinCode())) {
//
//            queryWrapper.lambda().last(", sort ASC, length(trim(diseases_name)) ASC");
//        }


        return new ResponseEntity<>(tcmDiseasesService.queryAll(criteria,pageable),HttpStatus.OK);
    }

}
